<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${config.sitename}"></title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <meta charset="utf-8">
    <meta name="keywords" th:content="${config.keywords}">
    <meta name="description" th:content="${config.description}">
    <meta content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <link rel="stylesheet" href="/static/css/pay.css">
    <link rel="stylesheet" href="/static/css/keyboard.css">
</head>
<body class="weui-wepay-pay-wrap">
<div class="pay-top">
    <form id="submitsss" action="/quickpass/pay" method="post">
        <input type="hidden" name="title" th:value="${config.panel}">
        <input type="hidden" name="payType" th:value="${payType}" id="fewfew">
        <input type="hidden" name="uid" th:value="${config.uid}">
        <input type="hidden" name="outOrderId" value="" id="dehwjnkdhbefiebdw"/>
        <input type="hidden" name="context" th:value="${config.liuyan}">
        <input type="hidden" name="price" value="" id="money">
        <div class="pay-shop-info">
            <div class="content">
                <img class="shop-logo"
                     th:src="'https://q4.qlogo.cn/headimg_dl?dst_uin='+${config.kfqq}+'&spec=100'" alt="">
                <span class="shop-name" th:text="${config.panel}"></span>
            </div>
        </div>
        <div class="pay-input-money">
            <div class="input-left">
                <span>输入消费金额</span>
            </div>
            <div class="input-right">
                <span>￥</span>
                <label id="paymoney" type="text"></label>
            </div>
        </div>
        <div class="upper-case2">
            <span class="upper-case-content" id="dwedewdew111">单号:</span>
        </div>
        <div class="upper-case">
            <span class="upper-case-content"></span>
        </div>
    </form>
</div>
<div class="payinfo">
    <table cellspacing="0" cellpadding="0">
        <tr>
            <td class="paynum">1</td>
            <td class="paynum">2</td>
            <td class="paynum">3</td>
            <td id="pay-return">
                <div class="keybord-return"></div>
            </td>
        </tr>
        <tr>
            <td class="paynum">4</td>
            <td class="paynum">5</td>
            <td class="paynum">6</td>
            <td rowspan="3" class="pay">
                <a href="javascript:return false;">
                    <div class="a-pay" >
                        <p>确认</p>
                        <p>支付</p>
                    </div>
                </a>
            </td>
        </tr>
        <tr>
            <td class="paynum">7</td>
            <td class="paynum">8</td>
            <td class="paynum">9</td>
        </tr>
        <tr>
            <td id="pay-zero" colspan="2" class="payzero">0</td>
            <td id="pay-float">.</td>
        </tr>
    </table>
</div>
</body>
<script type="text/javascript" charset="utf-8" src="/static/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">

    $(function () {

        $.post("/quickpass/orderid",
            {"times": new Date().getTime()},
            function (data) {
                $("#dehwjnkdhbefiebdw").val(data.oid);
                $("#dwedewdew111").html('<span style="color: blue;">单号:</span>&nbsp;<span style="color: #2b542c;">' + data.oid + '</span>');
            }, "json");


        $(".payinfo").slideDown();

        var $paymoney = $("#paymoney");

        var upperCaseMoney = $('.upper-case span');

        $('.pay').click(function(){
            console.log(($paymoney.text()));
            if (!$paymoney.text()) {
                upperCaseMoney.text('');
                $('.pay').addClass('pay-disabled').find('a').attr('href', 'javascript:return false;');
            }else{
                $('.pay').addClass('pay-disabled');
                $('.pay').html(' <p>正在</p> <p>支付</p>');
                $("#submitsss").submit();
            }
        });


        $("#paymoney").focus(function () {
            $(".payinfo").slideDown();
            document.activeElement.blur();
        });



        $(".paynum").each(function () {
            $(this).click(function () {
                if (($paymoney.text()).indexOf(".") != -1 && ($paymoney.text()).substring(($paymoney.text()).indexOf(".") + 1, ($paymoney.text()).length).length == 2) {
                    return;
                }
                if ($.trim($paymoney.text()) == "0") {
                    return;
                }
                if (parseInt($paymoney.text()) > 10000 && $paymoney.text().indexOf(".") == -1) {
                    return;
                }
                $('.pay').removeClass('pay-disabled');
                $paymoney.text($paymoney.text() + $(this).text());
                $("#money").val($paymoney.text());
                upperCaseMoney.text(digitUppercase($paymoney.text()));
                console.log(($paymoney.text()));
            });
        });



        $("#pay-return").click(function () {
            $paymoney.text(($paymoney.text()).substring(0, ($paymoney.text()).length - 1));
            upperCaseMoney.text(digitUppercase($paymoney.text()));
            console.log(($paymoney.text()));
            if (!$paymoney.text()) {
                upperCaseMoney.text('');
                $('.pay').addClass('pay-disabled').find('a').attr('href', 'javascript:return false;');
            }else{
                upperCaseMoney.text(digitUppercase($paymoney.text()));
                $('.pay').removeClass('pay-disabled').find('a').attr('href','javascript:void(0);');
            }
        });


        $("#pay-zero").click(function () {
            if (($paymoney.text()).indexOf(".") != -1 && ($paymoney.text()).substring(($paymoney.text()).indexOf(".") + 1, ($paymoney.text()).length).length == 2) {
                return;
            }
            if ($.trim($paymoney.text()) == "0") {
                return;
            }
            if (parseInt($paymoney.text()) > 10000 && $paymoney.text().indexOf(".") == -1) {
                return;
            }
            $('.pay').removeClass('pay-disabled');
            $paymoney.text($paymoney.text() + $(this).text());
            $("#money").val($paymoney.text());
            upperCaseMoney.text(digitUppercase($paymoney.text()));
            console.log(($paymoney.text()));
        });

        $("#pay-float").click(function () {
            if ($.trim($paymoney.text()) == "") {
                return;
            }
            if (($paymoney.text()).indexOf(".") != -1) {
                return;
            }
            if (($paymoney.text()).indexOf(".") != -1) {
                return;
            }
            $paymoney.text($paymoney.text() + $(this).text());
        });
        if (!$paymoney.text()) {
            $('.pay').addClass('pay-disabled');
        }
        console.log(($paymoney.text()));
    });


    (function () {
        var designW = 750;  //设计稿宽
        var font_rate = 100;
        //适配
        document.getElementsByTagName("html")[0].style.fontSize = document.body.offsetWidth / designW * font_rate + "px";
        document.getElementsByTagName("body")[0].style.fontSize = document.body.offsetWidth / designW * font_rate + "px";
        //监测窗口大小变化
        window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function () {
            document.getElementsByTagName("html")[0].style.fontSize = document.body.offsetWidth / designW * font_rate + "px";
            document.getElementsByTagName("body")[0].style.fontSize = document.body.offsetWidth / designW * font_rate + "px";
        }, false);
    })();



    var digitUppercase = function (n) {
        var fraction = ['角', '分'];
        var digit = [
            '零', '壹', '贰', '叁', '肆',
            '伍', '陆', '柒', '捌', '玖'
        ];
        var unit = [
            ['元', '万', '亿'],
            ['', '拾', '佰', '仟']
        ];
        var head = n < 0 ? '欠' : '';
        n = Math.abs(n);
        var s = '';
        for (var i = 0; i < fraction.length; i++) {
            s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
        }
        s = s || '整';
        n = Math.floor(n);
        for (var i = 0; i < unit[0].length && n > 0; i++) {
            var p = '';
            for (var j = 0; j < unit[1].length && n > 0; j++) {
                p = digit[n % 10] + unit[1][j] + p;
                n = Math.floor(n / 10);
            }
            s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
        }
        return head + s.replace(/(零.)*零元/, '元')
            .replace(/(零.)+/g, '零')
            .replace(/^整$/, '零元整');
    };



</script>
</html>

